package com.manlu.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.manlu.mapper.InterviewQuestionsMapper;
import com.manlu.pojo.InterviewQuestions;
import com.manlu.vo.BaseResult;
import com.manlu.vo.InterviewPageInfoVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Auther 漫路h
 * Created by 2020-05-04 20:49
 */
@Transactional
@Service
public class InterviewQuestionsService {
    @Resource
    private InterviewQuestionsMapper interviewQuestionsMapper;

    /**
     * 查询面试题列表(分页+条件)
     * @param interviewPageInfoVo
     * @return
     */
    public BaseResult selectAllByPageInfo(InterviewPageInfoVo interviewPageInfoVo) {
        //开启分页
        PageHelper.startPage(interviewPageInfoVo.getPageNum(),interviewPageInfoVo.getPageSize());
        //查询
        List<InterviewQuestions> list = interviewQuestionsMapper.selectAllByPageInfo(interviewPageInfoVo.getCid());
        //封装
        PageInfo<InterviewQuestions> pi = new PageInfo<>(list);
        return BaseResult.ok("ok",pi);
    }
}
